define(['handlebars','highchart'],
	function(Handlebars,highchart,deptSource,patientSource) {
	var $$ = Dom7;
	
	
	
	function chartClick(e){
		console.info("chartClick init...");
	}
	/**
	 * 生成饼图图表
	 * @param _options.container	容器对象id
	 * @param _options.title		标题
	 * @param _options.onClick		点击事件
	 * @param _options.data			数据对象
	 * @param _options.colors		图表颜色定义
	 * @param _options.legendLabel	提示栏文字格式
	 */
	function renderPie(_options){
		
		
		
		var _el = $(_options.container)
		_el.html('<div id="pie-content"></div>')
		
		//highcharts config
		var chartConfig ={
			chart: {
	            plotBackgroundColor: null,
	            plotBorderWidth: null,
	            plotShadow: false
	        },
	        credits:{
	        	enabled:false
	        },
	        title: {
	            text: false
	        },
	        tooltip: {
	            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
	        },
	        legend:{
	        	labelFormat: _options.legendLabel ,
	        	layout: 'vertical'
	            
	        },
	        plotOptions: {
	            pie: {
	                allowPointSelect: true,
	                cursor: 'pointer',
	                dataLabels: {
	                    enabled: false,
	                    distance:-20,
	                    format: '<b>{point.name}</b>:{point.y}件'
	                },
	                style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    },
                    showInLegend: true
	            }
	        }
		}
		
		var _colors = ["#ff0033","#99ccff",  "#99cc00"]
		
		//图表颜色设置
		Highcharts.getOptions().colors = Highcharts.map(_colors, function (color) {
	        return {
	            radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
	            stops: [
	                [0, color],
	                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
	            ]
	        };
	    });
		
		var _param ={
			title: {
	            text: _options.title
	        },
			series: [{
				allowPointSelect:true,
	            type: 'pie',
	            name: '所占比例',
	            data: _options.data,
	            events:{click:_options.onClick}
	        }]
		}
		
		_param =$.extend({},chartConfig,_param)
		$('#pie-content').highcharts(_param);
	}
	
	

	return {		
		renderPie	: renderPie
	}
});